package com.jiyun.controller;

import com.jiyun.pojo.Chat;
import com.jiyun.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
@RestController
@RequestMapping("/chat")
public class ChatController {
    @Autowired
    private ChatService chatService;
    @GetMapping("list")
    public List<Chat> list(){
        List<Chat> list= chatService.list();
        return list;
    }
    @GetMapping("/findchat")
    public List<Chat> findchat(@RequestParam("userId") Integer userId
            ,@RequestParam("driverId") Integer driverId){
       List<Chat> list= chatService.findchat(userId,driverId);
        return list;
    }
    @PostMapping("addchat")
    public void addchat(@RequestBody Chat chat){
        chat.setTime(new Date());
        chatService.save(chat);
    }
}
